/*
 * Copyright (C) 2012 Aonyx
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ch.aonyx.broker.ib.api.execution;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * @author Christophe Marcourt
 * @version 1.0.0
 */
public final class ExecutionReport {

	private static final String EMPTY = "";
	private String accountNumber = EMPTY;
	private double averageFilledPrice;
	private int clientId;
	private int cumulativeQuantity;
	private String exchange = EMPTY;
	private String executionId = EMPTY;
	private int liquidation;
	private int orderId;
	private String orderRef = EMPTY;
	private int permanentId;
	private double filledPrice;
	private int filledQuantity;
	private Side side = Side.EMPTY;
	private String time = EMPTY;

	public final String getAccountNumber() {
		return accountNumber;
	}

	public final void setAccountNumber(final String accountNumber) {
		this.accountNumber = accountNumber;
	}

	public final double getAverageFilledPrice() {
		return averageFilledPrice;
	}

	public final void setAverageFilledPrice(final double averageFilledPrice) {
		this.averageFilledPrice = averageFilledPrice;
	}

	public final int getClientId() {
		return clientId;
	}

	public final void setClientId(final int clientId) {
		this.clientId = clientId;
	}

	public final int getCumulativeQuantity() {
		return cumulativeQuantity;
	}

	public final void setCumulativeQuantity(final int cumulativeQuantity) {
		this.cumulativeQuantity = cumulativeQuantity;
	}

	public final String getExchange() {
		return exchange;
	}

	public final void setExchange(final String exchange) {
		this.exchange = exchange;
	}

	public final String getExecutionId() {
		return executionId;
	}

	public final void setExecutionId(final String executionId) {
		this.executionId = executionId;
	}

	public final int getLiquidation() {
		return liquidation;
	}

	public final void setLiquidation(final int liquidation) {
		this.liquidation = liquidation;
	}

	public final int getOrderId() {
		return orderId;
	}

	public final void setOrderId(final int orderId) {
		this.orderId = orderId;
	}

	public final String getOrderRef() {
		return orderRef;
	}

	public final void setOrderRef(final String orderRef) {
		this.orderRef = orderRef;
	}

	public final int getPermanentId() {
		return permanentId;
	}

	public final void setPermanentId(final int permanentId) {
		this.permanentId = permanentId;
	}

	public final double getFilledPrice() {
		return filledPrice;
	}

	public final void setFilledPrice(final double filledPrice) {
		this.filledPrice = filledPrice;
	}

	public final int getFilledQuantity() {
		return filledQuantity;
	}

	public final void setFilledQuantity(final int filledQuantity) {
		this.filledQuantity = filledQuantity;
	}

	public final Side getSide() {
		return side;
	}

	public final void setSide(final Side side) {
		this.side = side;
	}

	public final String getTime() {
		return time;
	}

	public final void setTime(final String time) {
		this.time = time;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(accountNumber).append(averageFilledPrice).append(clientId)
				.append(cumulativeQuantity).append(exchange).append(executionId).append(filledPrice)
				.append(filledQuantity).append(liquidation).append(orderId).append(orderRef).append(permanentId)
				.append(side).append(time).toHashCode();
	}

	@Override
	public boolean equals(final Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		if (obj.getClass() != getClass()) {
			return false;
		}
		final ExecutionReport rhs = (ExecutionReport) obj;
		return new EqualsBuilder().append(accountNumber, rhs.accountNumber)
				.append(averageFilledPrice, rhs.averageFilledPrice).append(clientId, rhs.clientId)
				.append(cumulativeQuantity, rhs.cumulativeQuantity).append(exchange, rhs.exchange)
				.append(executionId, rhs.executionId).append(filledPrice, rhs.filledPrice)
				.append(filledQuantity, rhs.filledQuantity).append(liquidation, rhs.liquidation)
				.append(orderId, rhs.orderId).append(orderRef, rhs.orderRef).append(permanentId, rhs.permanentId)
				.append(side, rhs.side).append(time, rhs.time).isEquals();
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}
}
